-
Notifications
You must be signed in to change notification settings - Fork 179
Cache VertexOnlyMesh for cross-mesh interpolation #4860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
connorjward
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the negativity, but caching correctly is really hard.
| """Return the symbolic ``Interpolate`` expressions for point evaluation and | ||
| re-ordering into the input-ordering VertexOnlyMesh. | ||
| @staticmethod | ||
| def _vom_cache_key(target_space, source_mesh, allow_missing_dofs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this just be a cached property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
| self.allow_missing_dofs, | ||
| ) | ||
| try: | ||
| return _vom_cache[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this. The communicator is only implicitly part of this cache key so I think deadlocks could well happen.
Also you are using source_mesh as the key, creating a reference to it and meaning that it will never be cleared from the memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the correct way to do this then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step 1 is choosing an object to tie the lifetime of the VoM to. It's probably best to use source_mesh here.
I have implemented a fair amount of caching support that would easily handle this in pyop3, so you may want to wait for that or just port the (small) amount of code over that you need.
Cache the vom used for cross-mesh interpolation. Consider the following
The assembly of
h2previously took ~5s on my machine, with caching it now takes ~0.012s